package com.shuke.my_test.tree_lazy.mapper;


import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.shuke.my_test.tree_lazy.domain.LabelType;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Set;

/**
 * @author 舒克、舒克
 * @date 2025/5/6 17:03
 * @description
 */
@Mapper
public interface LabelTypeMapper extends BaseMapper<LabelType> {


    /**
     * 批量查询（启用性能优化配置）
     * 建议使用覆盖索引：CREATE INDEX idx_covering ON t_label_type(id, parent_id, name)
     */
    @Select("<script>" +
            "SELECT id, name, parent_id FROM t_label_type WHERE parent_id IN " +
            "<foreach collection='parentIds' item='parentId' open='(' separator=',' close=')'>" +
            "#{parentId}" +
            "</foreach>" +
            "</script>")
    List<LabelType> batchSelectByParent(Set<Integer> parentIds);
}
